<div class="refentry"><a id="glTexBuffer"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glTexBuffer — attach the storage for a buffer object to the active buffer texture</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table class="funcprototype-table" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <strong class="fsfunc">glTexBuffer</strong>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">internalFormat</var>, </td></tr><tr><td> </td><td>GLuint <var class="pdparam">buffer</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>target</code></em></span></dt><dd><p>
                    Specifies the target of the operation and must be <code class="constant">GL_TEXTURE_BUFFER</code>.
                </p></dd><dt><span class="term"><em class="parameter"><code>internalFormat</code></em></span></dt><dd><p>
                    Specifies the internal format of the data in the store belonging to <em class="parameter"><code>buffer</code></em>.
                </p></dd><dt><span class="term"><em class="parameter"><code>buffer</code></em></span></dt><dd><p>
                    Specifies the name of the buffer object whose storage to attach to the active buffer texture.
                </p></dd></dl></div></div><div class="refsect1"><a id="description"></a><h2>Description</h2><p>
            <code class="function">glTexBuffer</code> attaches the storage for the buffer object named <em class="parameter"><code>buffer</code></em> to the active
            buffer texture, and specifies the internal format for the texel array found in the attached buffer object. If <em class="parameter"><code>buffer</code></em>
            is zero, any buffer object attached to the buffer texture is detached and no new buffer object is attached. If <em class="parameter"><code>buffer</code></em>
            is non-zero, it must be the name of an existing buffer object. <em class="parameter"><code>target</code></em> must be <code class="constant">GL_TEXTURE_BUFFER</code>.
            <em class="parameter"><code>internalformat</code></em> specifies the storage format, and must be one of the following sized internal formats:
        </p><div class="informaltable"><table><colgroup><col class="col1" /><col class="col2" /><col class="col3" /><col class="col4" /><col class="col5" /><col class="col6" /><col class="col7" /><col class="col8" /></colgroup><thead><tr><th rowspan="2" class="center"><strong>Sized Internal Format</strong></th><th rowspan="2" class="center"><strong>Base Type</strong></th><th rowspan="2" class="center"><strong>Components</strong></th><th rowspan="2" class="center"><strong>Norm</strong></th><th colspan="4"><span class="bold"><strong>
                        Component
                        </strong></span></th></tr><tr><td class="center">0</td><td class="center">1</td><td class="center">2</td><td class="center">3</td></tr></thead><tbody><tr><td><code class="constant">GL_R8</code></td><td>ubyte</td><td>1</td><td>YES</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R16</code></td><td>ushort</td><td>1</td><td>YES</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R16F</code></td><td>half</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R32F</code></td><td>float</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R8I</code></td><td>byte</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R16I</code></td><td>short</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R32I</code></td><td>int</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R8UI</code></td><td>ubyte</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R16UI</code></td><td>ushort</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_R32UI</code></td><td>uint</td><td>1</td><td>NO</td><td class="center">R</td><td class="center">0</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG8</code></td><td>ubyte</td><td>2</td><td>YES</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG16</code></td><td>ushort</td><td>2</td><td>YES</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG16F</code></td><td>half</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG32F</code></td><td>float</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG8I</code></td><td>byte</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG16I</code></td><td>short</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG32I</code></td><td>int</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG8UI</code></td><td>ubyte</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG16UI</code></td><td>ushort</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RG32UI</code></td><td>uint</td><td>2</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">0</td><td class="center">1</td></tr><tr><td><code class="constant">GL_RGBA8</code></td><td>uint</td><td>4</td><td>YES</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA16</code></td><td>short</td><td>4</td><td>YES</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA16F</code></td><td>half</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA32F</code></td><td>float</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA8I</code></td><td>byte</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA16I</code></td><td>short</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA32I</code></td><td>int</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA8UI</code></td><td>ubyte</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA16UI</code></td><td>ushort</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr><tr><td><code class="constant">GL_RGBA32UI</code></td><td>uint</td><td>4</td><td>NO</td><td class="center">R</td><td class="center">G</td><td class="center">B</td><td class="center">A</td></tr></tbody></table></div><p>
            When a buffer object is attached to a buffer texture, the buffer object's data store
            is taken as the texture's texel array.  The number of texels in the buffer texture's
            texel array is given by
        </p><math overflow="scroll">
            <mo>⌊</mo>
            <mfrac>
                <mrow>
                    <mi>buffer_size</mi>
                </mrow>
                <mrow>
                    <mi>components</mi><mo>×</mo><mi>sizeof</mi><mo>(</mo><mi>base_type</mi><mo>)</mo>
                </mrow>
            </mfrac>
            <mo>⌋</mo>
        </math><p>
            where <span class="emphasis"><em>buffer_size</em></span> is the size of the buffer object, in basic machine units and
            components and base type are the element count and base data type for elements, as specified in the table above.
            The number of texels in the texel array is then clamped to the implementation-dependent limit <code class="constant">GL_MAX_TEXTURE_BUFFER_SIZE</code>.
            When a buffer texture is accessed in a shader, the results of a texel fetch are undefined if the specified texel coordinate is negative, or
            greater than or equal to the clamped number of texels in the texel array.
        </p></div><div class="refsect1"><a id="errors"></a><h2>Errors</h2><p>
            <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>target</code></em> is not <code class="constant">GL_TEXTURE_BUFFER</code>.
        </p><p>
            <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>internalFormat</code></em> is not one of the accepted tokens.
        </p><p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated if <em class="parameter"><code>buffer</code></em> is not zero or the name of an existing buffer object.
        </p></div><div class="refsect1"><a id="notes"></a><h2>Notes</h2><p>
            <code class="function">glTexBuffer</code> is available only if the GL version is 3.1 or greater.
        </p></div><div class="refsect1"><a id="associatedgets"></a><h2>Associated Gets</h2><p><a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a>
    with argument <code class="constant">GL_MAX_TEXTURE_BUFFER_SIZE</code></p><p><a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a>
    with argument <code class="constant">GL_TEXTURE_BINDING_BUFFER</code></p><p><a class="citerefentry" href="glGetTexLevelParameter"><span class="citerefentry"><span class="refentrytitle">glGetTexLevelParameter</span></span></a>
    with argument <code class="constant">GL_TEXTURE_BUFFER_DATA_STORE_BINDING</code></p></div>
        {$pipelinestall}{$examples}
        <div class="refsect1"><a id="seealso"></a><h2>See Also</h2><p>
            <a class="citerefentry" href="glGenBuffers"><span class="citerefentry"><span class="refentrytitle">glGenBuffers</span></span></a>,
            <a class="citerefentry" href="glBindBuffer"><span class="citerefentry"><span class="refentrytitle">glBindBuffer</span></span></a>,
            <a class="citerefentry" href="glBufferData"><span class="citerefentry"><span class="refentrytitle">glBufferData</span></span></a>,
            <a class="citerefentry" href="glDeleteBuffers"><span class="citerefentry"><span class="refentrytitle">glDeleteBuffers</span></span></a>,
            <a class="citerefentry" href="glGenTextures"><span class="citerefentry"><span class="refentrytitle">glGenTextures</span></span></a>,
            <a class="citerefentry" href="glBindTexture"><span class="citerefentry"><span class="refentrytitle">glBindTexture</span></span></a>,
            <a class="citerefentry" href="glDeleteTextures"><span class="citerefentry"><span class="refentrytitle">glDeleteTextures</span></span></a>
        </p></div><div class="refsect1"><div id="Copyright"><h2>Copyright</h2><p>
            Copyright © 2010-2013 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <a class="ulink" href="http://opencontent.org/openpub/" target="_top">http://opencontent.org/openpub/</a>.
        </p></div></div></div>
